﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface;
using Ewma.Data;

namespace Ewma
{
    public abstract class AuthorizedService<T> : ServiceBase<T> where T : AuthorizedQuery
    {
        // TODO : This class should go in the Streambolics.WebServices assembly

        private Player _Player;

        protected override object Run (T request)
        {
            // TODO : Obtain a database connection and check the identity
            _Player = new Player ();
            return RunWithIdentity (request);
        }

        protected abstract object RunWithIdentity (T aRequest);

        protected Player Player
        {
            get
            {
                return _Player;
            }
        }
    }
}